﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
#if NativeCov
using ExcelRef = Microsoft.Office.Interop.Excel;
#endif
using System.IO;
using System.Threading;
using System.Configuration;

namespace FX.CC.Andon.EqKanban
{
    public partial class frmManualViewDoc : Form
    {
        IList<int> allowPages;
        int idx;
        public frmManualViewDoc()
        {
            InitializeComponent();
        }

        public void SetPdfFileName(string setFileName, IList<int> pages) {
            string shortFileName =  setFileName.Split('/').Last();
            string fullFileName = Application.StartupPath + "\\Doc\\" + shortFileName;
            this.allowPages = pages;
            try
            {
                if (File.Exists(fullFileName))
                {
                    axAcroPDF1.LoadFile(fullFileName);
                    if (pages.Count > 0) {
                        int firstPage = pages.First();
                        axAcroPDF1.setCurrentPage(firstPage);
                        idx = 0;
                    }
                }
            }
            catch { }
        }

        public void ShowNextPage() {
            int newIdx = idx + 1;
            if (newIdx < allowPages.Count)
            {
                try
                {
                    //axAcroPDF1.gotoNextPage();
                    axAcroPDF1.setCurrentPage(allowPages[newIdx]);
                    idx = newIdx;
                }
                catch { }
            }
        }

        public void ShowPreviousPage()
        {
            int newIdx = idx - 1;
            if (newIdx >=0)
            {
                try
                {
                    //axAcroPDF1.gotoPreviousPage();
                    axAcroPDF1.setCurrentPage(allowPages[newIdx]);
                    idx = newIdx;
                }
                catch { }
            }
        }

        public void CloseForm() {
            this.Close();
        }
    }
}
